import axios from '../../models/http'

// const akKey = 'TKtbOAvNywDHNpej8d5rI0LnWANOa1kU'

export default {
  /**
   * @param { username, password }
   * @method POST
   */
  async login(user) {
    try {
      const res = await axios.post('/api/users/login', user)
      return res;
    } catch(ex) {
      throw ex;
    }
  },
  /**
   * @param { username, password, age }
   * @method POST
   */
  async register(user) {
    try {
      const res = await axios.post('/api/users/register', user)
      return res;
    } catch(ex) {
      throw ex;
    }
  },
  /**
   * @param { username }
   * @method POST
   */
  async checkUser(user) {
    try {
      const res = await axios.post('/api/users/checkusername', user)
      return res;
    } catch(ex) {
      throw ex;
    }
  },
  /**
   * @param { username }
   * @method GET
   */
  async getAllusers() {
    try {
      const res = await axios.get('/api/users/getAllusers')
      return res;
    } catch(ex) {
      throw ex;
    }
  },
  /**
   * @param { id }
   * @method GET
   */
  async findUserById(id) {
    try {
      const res = await axios.get('/api/users/findUser', id)
      return res;
    } catch(ex) {
      throw ex;
    }
  },
   /**
   * @param { age, area }
   * @method POST
   */
  async updateById(data) {
    try {
      const res = await axios.post('/api/users/updateUser', data)
      return res;
    } catch(ex) {
      throw ex;
    }
  },
}